package com.vote.services.impl;

import org.apache.log4j.Logger;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;

import com.vote.services.GroupService;

public class GroupServiceImpl implements GroupService{
	/**
	 * Logger for this class
	 */
	private static final Logger logger = Logger.getLogger(GroupServiceImpl.class);

	private List<String> groupList = null;
	private String groupStr;
	
	public void init(){
		String[] ss = groupStr.split("\\|");
		groupList = Arrays.asList(ss);
		logger.debug("load group list success:"+groupList.toString());
		return;
	}
	
	@Override
	public int getGroupCount() {
		return groupList.size();
	}

	@Override
	public List<String> getGroupList() {
		return groupList;
	}

	@Override
	public String getGroupNameById(int id) {
		if(id < 0 || id >= groupList.size())
			return null;
		else
			return groupList.get(id);
	}

	public void setGroupStr(String groupStr) {
		this.groupStr = groupStr;
	}

	public String getGroupStr() {
		return groupStr;
	}

}
